#!/bin/sh
set -eu

jdk_base_dir="/usr/lib/jvm/@jvm_dir@"
tools="@jvm_tools@"

case "$1" in
purge)
	# Nothing to do
	;;
remove | upgrade | failed-upgrade | abort-install | abort-upgrade | disappear | deconfigure)
	for tool in $tools; do
		for tool_path in "$jdk_base_dir/bin/$tool" "$jdk_base_dir/lib/$tool"; do
			if [ ! -e "$tool_path" ]; then
				continue
			fi

			update-alternatives --remove "$tool" "$tool_path"
		done
	done
	;;
*)
	echo "prerm called with unknown argument \`$1'" >&2
	exit 1
	;;
esac

exit 0
